library ForwardObserverTraining initializer init requires LegacySystem

	private function C takes nothing returns boolean
		return GetLearnedSkill() == 'A091'
	endfunction

	private function A takes nothing returns nothing
		local unit u = GetTriggerUnit()
		local integer level = GetUnitAbilityLevel(u, 'A091') 
		local player p = GetOwningPlayer(u)
		local integer i = 1

		call SetPlayerTechResearched(p, 'R000', level)
		
		if( level == 4 ) then
			loop
                exitwhen i>udg_Players
                call CreateUnit(ConvertedPlayer(udg_Sorted[i]),'e006',1900.0,4300.0,0.0)
                call TriggerSleepAction(0.)
                set i=i+1
			endloop
		endif
		
		set u = null
		set p = null

	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
		call TriggerAddCondition( t, Condition( function C ) )
		call TriggerAddAction( t, function A )
	endfunction

endlibrary